<template>
	<div>
		<!-- 顶部选项卡 -->
		<scroll-view class="pagecontrol-top-scroll" scroll-x="true" scroll-with-animation
			:scroll-into-view="scrollInto">
			<view class="pagecontrol-top-title">
				<view v-for="(items, index) in itemsArr" :key="index" class="pagecontrol-top-text"
					@click="changeTab(index)" :id="'tab' + index">
					<view :class="tabIndex === index ? 'pagecontrol-top-selected' : 'pagecontrol-top-normal'">
						{{ items }}
					</view>
					<view class="pagecontrol-bottom-line"
						:class="tabIndex === index ? 'pagecontrol-bottom-line-show' : 'pagecontrol-bottom-line-visibility'">
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- 内容 -->
		<swiper :duration="150" :current="tabIndex" @change="onChangeTab" :style="'height:' + scrollH + 'px;'">
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'">
					<!--基本资料-->
					<view style="padding-bottom: 100px;">
						<view style="background-color: #ffffff;margin: 10px;border-radius: 12px;padding: 15px;">
							<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="90px">
								<uni-forms-item label="司机姓名" name="driverName" required>
									<uni-easyinput type="text" v-model="formData.driverName" placeholder="请输入司机姓名" />
								</uni-forms-item>
								<uni-forms-item label="性别" name="sex" required>
									<uni-data-checkbox v-model="formData.sex" :localdata="sex" />
								</uni-forms-item>
								<uni-forms-item label="身份证号" name="idCardNo" required>
									<uni-easyinput type="number" v-model="formData.idCardNo" placeholder="请输入身份证" />
								</uni-forms-item>
								<uni-forms-item label="司机类型" name="driverType" required>
									<uni-data-select v-model="formData.driverType" :localdata="driverType"
										style="background-color: white;" />
								</uni-forms-item>
								<uni-forms-item label="所在地址" name="addressDistrictId" required>
									<uni-data-picker placeholder="请选择地址" popup-title="请选择所在地区" :localdata="addressDistrictId"
										style="background-color: white;" v-model="formData.addressDistrictId">
									</uni-data-picker>
									<view style="margin-top: 20px;">
										<uni-easyinput type="text"
											v-model="formData.address" placeholder="请输入详细地址" />
									</view>
								</uni-forms-item>
								<uni-forms-item label="手机号码" name="phoneNumber" required>
									<uni-easyinput type="number" @change="changePhone" v-model="formData.phoneNumber" placeholder="请输入手机号码" />
								</uni-forms-item>
								<uni-forms-item label="驾照类型" name="licenseType" required>
									<uni-data-select v-model="formData.licenseType" :localdata="licenseType"
										style="background-color: white;" />
								</uni-forms-item>
								<uni-forms-item label="驾照证号" name="driverLicenseNo">
									<uni-easyinput type="text" v-model="formData.driverLicenseNo" placeholder="请输入驾照证号" />
								</uni-forms-item>
								<uni-forms-item label="驾龄" name="drivingYears">
									<uni-easyinput type="number" v-model="formData.drivingYears" placeholder="请输入驾龄" />
								</uni-forms-item>
								<uni-forms-item label="驾驶证起始日期" name="driverLicenseStartDate">
									<uni-datetime-picker type="date" v-model="formData.driverLicenseStartDate" />
								</uni-forms-item>
								<uni-forms-item label="驾驶证到期日期" name="driverLicenseExpireDate">
									<uni-datetime-picker type="date" v-model="formData.driverLicenseExpireDate" />
								</uni-forms-item>
								<uni-forms-item label="车牌号" name="plateNumber">
									<uni-combox @input="inputPlateNumber" :candidates="plateNumber" placeholder="输入检索车牌号"
										v-model="formData.plateNumber"></uni-combox>
									<view v-if="carInfo.carId">
										{{carType[carInfo.carType]}} {{carInfo.carLength}}米，行驶证号：{{carInfo.drivingLicenseNo}}
									</view>
								</uni-forms-item>
								<uni-forms-item label="相关资料">
									<myfilepicker :limit="'1'" :imageStyles="imageStyles" :fileIdString="formData.avatarAttachment" :fileExtname="'png,jpg,jpeg'" :fileMediatype="'image'"  @transFileIdString="getFileIdString_avatarAttachment"
											:title="'*点击上传个人头像，支持png/jpg/jpeg，最多可上传1个附件*'"><uni-icons type="cloud-upload" size="18"></uni-icons>个人头像</myfilepicker>
									<view style="margin-top: 10px;">
										<myfilepicker :limit="'1'" :imageStyles="imageStyles" :fileIdString="formData.idCardAttachment" :fileExtname="'png,jpg,jpeg'" :fileMediatype="'image'"  @transFileIdString="getFileIdString_idCardAttachment"
												:title="'*点击上传身份证(正面)，支持png/jpg/jpeg，最多可上传1个附件*'"><uni-icons type="cloud-upload" size="18"></uni-icons>身份证(正面)</myfilepicker>
									</view>
									<view style="margin-top: 10px;">
										<myfilepicker :limit="'1'" :imageStyles="imageStyles" :fileIdString="formData.idCardReverseAttachment" :fileExtname="'png,jpg,jpeg'" :fileMediatype="'image'"  @transFileIdString="getFileIdString_idCardReverseAttachment"
												:title="'*点击上传身份证(反面)，支持png/jpg/jpeg，最多可上传1个附件*'"><uni-icons type="cloud-upload" size="18"></uni-icons>身份证(反面)</myfilepicker>
									</view>
									<view style="margin-top: 10px;">
										<myfilepicker :limit="'1'" :imageStyles="imageStyles" :fileIdString="formData.driverLicenseAttachment" :fileExtname="'png,jpg,jpeg'" :fileMediatype="'image'"  @transFileIdString="getFileIdString_driverLicenseAttachment"
												:title="'*点击上传驾驶证，支持png/jpg/jpeg，最多可上传1个附件*'"><uni-icons type="cloud-upload" size="18"></uni-icons>驾驶证</myfilepicker>
									</view>
									<view style="margin-top: 10px;">
										<myfilepicker :limit="'1'" :imageStyles="imageStyles" :fileIdString="formData.personWithCarAttachment" :fileExtname="'png,jpg,jpeg'" :fileMediatype="'image'"  @transFileIdString="getFileIdString_personWithCarAttachment"
												:title="'*点击上传人照合一，支持png/jpg/jpeg，最多可上传1个附件*'"><uni-icons type="cloud-upload" size="18"></uni-icons>人照合一</myfilepicker>
									</view>
									<view style="margin-top: 10px;">
										<myfilepicker :limit="'3'"  :fileIdString="formData.otherAttachment" :fileExtname="'pdf,png,gif,jpg,jpeg,doc,docx'" :fileMediatype="'all'"  @transFileIdString="getFileIdString_otherAttachment"
												:title="'*点击上传其他附件，支持pdf/doc/docx/jpg/jpeg/png/gif，最多可上传3个附件*'"></myfilepicker>
									</view>
								</uni-forms-item>
								<uni-forms-item label="备注" name="remark">
									<uni-easyinput type="textarea" v-model="formData.remark" placeholder="司机相关备注说明" />
								</uni-forms-item>
								<uni-forms-item label="是否开通创建账户">
									<uni-data-checkbox @change="changeOpenAccount" v-model="isOpenAccount" :localdata="openAccount" />
									<!-- <uni-easyinput v-if="isOpenAccount=='1'" type="text" disabled v-model="formData.openAccount" placeholder="开通账号" /> -->
									<view v-if="isOpenAccount=='1'" style="display: flex;margin-top: 10px;">
										当前开通账号：{{formData.openAccount}}
									</view>
									<view style="display: flex;margin-top: 10px;font-size: 12px;">
										选择是，则新增司机的同时自动创建账号，账号名同司机手机号码，将发送创建账号、密码至手机号码
									</view>
								</uni-forms-item>
							</uni-forms>
							
						</view>
					</view>
				</scroll-view>
				<view
					style="background-color: #ffffff;z-index: 3;height: 70px;width:100%;position: fixed;bottom: 0;display: flex;box-shadow: 0px 0px 11px rgba(0, 0, 0, 0.1);">
					<view
						style="display: flex;align-items: center;width: 100%;height: 60px;justify-content: center;">
						<view v-if="driverId==''" @click="submit()" hover-class="buttonHover"
							style="height: 35px;background-color: #bf5f09;color: #ffffff;width: 100px;display: flex;justify-content: center;align-items: center;border-radius: 4px;">
							确定新增</view>
						<view v-else @click="submit_update()" hover-class="buttonHover"
							style="height: 35px;background-color: #bf5f09;color: #ffffff;width: 100px;display: flex;justify-content: center;align-items: center;border-radius: 4px;">
							保存</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<scroll-view scroll-y="true" show :style="'height:' + scrollH + 'px;'">
					<!--常跑路线-->
					<view  style="padding-bottom: 100px;">
						<view v-for="(item,index) in formData.driverLineList" :key="index" style="display: flex;flex-direction: row;padding: 10px;justify-content: space-between;background-color: white;margin: 10px;border-radius: 12px;">
							<view style="display: flex;flex-direction: column;">
								<view style="display: flex;align-items: center;">
									<view style="width: 25px;height: 25px;border: 1px solid rgb(91, 86, 86);display: flex;justify-content: center;align-items: center;">
										起
									</view>
									<view style="display: flex;flex-direction: column;margin-left: 10px;margin-right: 10px">
										<!-- <uni-data-picker placeholder="请选择起始地址" popup-title="请选择所在地区" :localdata="addressDistrictId"
											style="background-color: white;" v-model="item.departDistrict">
										</uni-data-picker> -->
										<text>{{item.departDistrictName}}</text>
									</view>
								</view>
							    <view style="display: flex;align-items: center;margin-top: 15px;">
									<view style="width: 25px;height: 25px;border: 1px solid rgb(91, 86, 86);display: flex;justify-content: center;align-items: center;">
										止
									</view>
									<view style="display: flex;flex-direction: column;margin-left: 10px;margin-right: 10px">
										<!-- <uni-data-picker placeholder="请选择目的地址" popup-title="请选择所在地区" :localdata="addressDistrictId"
											style="background-color: white;" v-model="item.arriveDistrict">
										</uni-data-picker> -->
										<text>{{item.arriveDistrictName}}</text>
									</view>
									
								</view>
							</view>
							<view style="display: flex;flex-direction: column;justify-content: space-around;">
								<button @click="editDriverLineList(index)" hover-class="buttonHover" type="primary" 
									style="color:#ffffff;background-color:#bf5f09;font-size: 13px;width: 60px;height: 30px;">编辑</button>
								<button @click="deleteDriverLineList(index)" hover-class="buttonHover" type="primary"
									style="color:#ffffff;background-color:#bf5f09;font-size: 13px;width: 60px;height: 30px;">删除</button>
							</view>
							
						</view>
						<!-- <view @click="addLine" hover-class="buttonHover" style="position: fixed;left: 50%;transform:translateX(-50%);bottom:10px;width: 100px;height:35px;color:#ffffff;background-color:#bf5f09;border-radius: 4px;display:flex;justify-content: center;align-items: center;">
							新增线路
						</view> -->
						<view @click="addLine" hover-class="buttonHover" style="position: fixed;right: 15px;bottom:100px;width: 50px;height:50px;color:#ffffff;background-color:#bf5f09;border-radius: 50%;display:flex;justify-content: center;align-items: center;box-shadow: 0 1px 5px 2px rgba(0, 0, 0, 0.3);">
							<uni-icons type="plusempty" size="30" color="#ffffff"></uni-icons>
						</view>
					</view>
				</scroll-view>
				<view
					style="background-color: #ffffff;z-index: 3;height: 70px;width:100%;position: fixed;bottom: 0;display: flex;box-shadow: 0px 0px 11px rgba(0, 0, 0, 0.1);">
					<view
						style="display: flex;align-items: center;width: 100%;height: 60px;justify-content: center;">
						<view v-if="driverId==''" @click="submit()" hover-class="buttonHover"
							style="height: 35px;background-color: #bf5f09;color: #ffffff;width: 100px;display: flex;justify-content: center;align-items: center;border-radius: 4px;">
							确定新增</view>
						<view v-else @click="submit_update()" hover-class="buttonHover"
							style="height: 35px;background-color: #bf5f09;color: #ffffff;width: 100px;display: flex;justify-content: center;align-items: center;border-radius: 4px;">
							保存</view>
					</view>
				</view>
			</swiper-item>
		</swiper>
		
		<!-- 新增路线弹窗 -->
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="新增路线" @confirm="dialogConfirm" :before-close="true" @close="this.$refs.alertDialog.close()">
				<scroll-view scroll-top="0" scroll-y="true" style="height: 116px;">
					<view style="display: flex;flex-direction: column;width: 100%;">
						<uni-forms labelWidth="75px">
							<uni-forms-item label="起始地址">
								<uni-data-picker @change="getDepartDistrictName" placeholder="请选择起始地址" popup-title="请选择所在地区" :localdata="addressDistrictId"
									style="background-color: white;" v-model="departDistrict">
								</uni-data-picker>
							</uni-forms-item>
							<uni-forms-item label="目的地址">
								<uni-data-picker @change="getArriveDistrictName" placeholder="请选择目的地址" popup-title="请选择所在地区" :localdata="addressDistrictId"
									style="background-color: white;" v-model="arriveDistrict">
								</uni-data-picker>
							</uni-forms-item>
						</uni-forms>
					</view>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
	</div>
</template>

<script>
	import {
		getDriverDetails,
		addDriver,
		updateDriverProfile,
		getCarrierCarList,
		getCarrierCarDetails
	} from '@/api/system/driver.js'
	import {getDicts,getAllAddressTree} from '@/api/system/dict.js'
	import myfilepicker from '@/components/uploadFile/uploadFile.vue'
	
	export default {
		components: {
			myfilepicker
		},
		data() {
			return {
				itemsArr: ['基本资料','常跑路线'],
				tabIndex: 0,
				scrollH: 700,
				scrollInto: '',
				formData: {
					driverName: '',
					sex:'',
					idCardNo:'',
					driverType: '',
					addressDistrictId: '',
					address: '',
					phoneNumber: '',
					licenseType:'',
					driverLicenseNo:'',
					drivingYears:'',
					driverLicenseStartDate:'',
					driverLicenseExpireDate:'',
					plateNumber:'',
					
					avatarAttachment:'',
					idCardAttachment:'',
					driverLicenseAttachment:'',
					personWithCarAttachment:'',
					otherAttachment:'',

					remark: '',
					enableStatus:'0',
					openAccount:'',
					driverLineList:[]
				},
				// 校验规则
				rules: {
					driverName: {
						rules: [{
							required: true,
							errorMessage: '请输入司机姓名',
						}]
					},
					sex: {
						rules: [{
							required: true,
							errorMessage: '请选择性别',
						}]
					},
					idCardNo: {
						rules: [{
							required: true,
							errorMessage: '请输入身份证号',
						},
						{
						    pattern: '(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)',
						    errorMessage: "请输入正确的身份证号"
						}
						]
					},
					phoneNumber: {
						rules: [{
							required: true,
							errorMessage: '请输入手机号码',
						},
						{
						    pattern: '^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$',
						    errorMessage: '电话格式不正确'
						}
						]
					},
					driverType: {
						rules: [{
							required: true,
							errorMessage: '请选择司机类型',
						}]
					},
					addressDistrictId: {
						rules: [{
							required: true,
							errorMessage: '请选择所在地址',
						}]
					},
					licenseType: {
						rules: [{
							required: true,
							errorMessage: '请选择驾照类型',
						}]
					}
				},
				// 性别->单选数据源
				sex: [],
				isOpenAccount:'0',
				//开通账号标识
				openAccount:[
					{
						value:'0',
						text:'否'
					},
					{
						value:'1',
						text:'是'
					}
				],
				//地区下拉框
				addressDistrictId: [],
				//下拉框 ->司机类型
				driverType: [],
				//下拉框 ->驾照类型
				licenseType: [],
				//下拉框 ->车牌号
				plateNumber: [],
				imageStyles: {
					width: '100%',
					height: 200,
					border: {
						radius: '4px'
					}
					
				},
				driverId:'',
				//节流函数标志
				statu:true,
				carInfo:[],
				carType:[],
				
				//弹窗的起始地址
				departDistrict:'',
				departDistrictName:'',
				arriveDistrict:'',
				arriveDistrictName:'',
				
				//编辑序号index
				editDriverLineIndex:'',
			}
		},
		onLoad(e) {
			uni.getSystemInfo({
				success: res => {
					this.scrollH = res.windowHeight - 40;
				}
			});
			
			if (e.driverId) {
				//设置顶部导航栏标题
				uni.setNavigationBarTitle({
					title: '编辑司机'
				})
			
				uni.showLoading({
					title: '正在加载',
				})
				this.driverId = e.driverId
				//获取司机详情
				getDriverDetails(e.driverId).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						this.formData = res.data
						
						//是否开通账号
						if(this.formData.openAccount!=null&&this.formData.openAccount!=''&&this.formData.openAccount!='0'&&this.formData.enableStatus=='1')
						{
							//是
							this.isOpenAccount='1'
						}
						else this.isOpenAccount='0'
							
					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			}
		},
		created() {
			//获取性别下拉框
			getDicts('sys_user_sex').then(res=>{
				this.sex=res.data.map(item=>{
					return {
						value:item.dictValue,
						text:item.dictLabel
					}
				})
			})
			
			//获取司机类型下拉框
			getDicts('driver_type').then(res=>{
				this.driverType=res.data.map(item=>{
					return {
						value:item.dictValue,
						text:item.dictLabel
					}
				})
			})
			
			//获取驾照类型下拉框
			getDicts('license_type').then(res=>{
				this.licenseType=res.data.map(item=>{
					return {
						value:item.dictValue,
						text:item.dictLabel
					}
				})
			})
			
			//获取车牌号下拉框
			getCarrierCarList({pageNum:1,pageSize:1000}).then(res=>{
				this.plateNumber=res.rows.map(item=>{
					return item.licensePlate
				})
			})
			
			//加载车辆类型
			getDicts('car_type').then(res=>{
				res.data.forEach(item=>{
					this.carType[item.dictValue]=item.dictLabel
				})
			})
			
			//获取全国地址信息->地区下拉框
			getAllAddressTree().then(res=>{
				this.addressDistrictId=res.data
			})
		},
		methods: {
			//接收文件传递的id字符串集合
			getFileIdString_avatarAttachment(fileIds){
				this.formData.avatarAttachment=fileIds
			},
			//接收文件传递的id字符串集合
			getFileIdString_idCardAttachment(fileIds){
				this.formData.idCardAttachment=fileIds
			},
			//接收文件传递的id字符串集合
			getFileIdString_idCardReverseAttachment(fileIds){
				this.formData.idCardReverseAttachment=fileIds
			},
			//接收文件传递的id字符串集合
			getFileIdString_driverLicenseAttachment(fileIds){
				this.formData.driverLicenseAttachment=fileIds
			},
			//接收文件传递的id字符串集合
			getFileIdString_personWithCarAttachment(fileIds){
				this.formData.personWithCarAttachment=fileIds
			},
			//接收文件传递的id字符串集合
			getFileIdString_otherAttachment(fileIds){
				this.formData.otherAttachment=fileIds
			},
			//开通账号单选框
			changeOpenAccount(){
				//开通账号
				if(this.isOpenAccount=='1')
				{
					this.formData.enableStatus=1
					this.formData.openAccount=this.formData.phoneNumber;
				}
				else
				{
					this.formData.enableStatus=0
					this.formData.openAccount=null;
				}
			},
			// 切换选项
			changeTab(index) {
				if (this.tabIndex === index) {
					return;
				}
				this.tabIndex = index;
				// 滚动到指定元素
				this.scrollInto = 'tab' + index;
			},
			// 监听滑动
			onChangeTab(e) {
				uni.showLoading({
					title: '正在加载',
				})
				setTimeout(function() {
					uni.hideLoading()
				}, 500);
				this.changeTab(e.detail.current);
			},
			//弹出层
			addContract(){
				uni.navigateTo({
					url:'/pages/user/addCarrier/addContract'
				})
			},
			//改变手机号
			changePhone(e){
				//开通账号
				if(e)
				{
					this.formData.openAccount=this.formData.phoneNumber;
				}
				else
				{
					this.formData.openAccount=null;
				}
			},
			//车牌号
			inputPlateNumber(e){
				if(e)
				{
					//节流函数
					let that=this
					if(!that.statu)
					{
						return
					}
					that.statu=false
					setTimeout(()=>{
						getCarrierCarDetails(e).then(res=>{
							if(res.data) that.carInfo=res.data;
							else that.carInfo=[];
						})
						that.statu=true;
					},1000)
					
				}
			},
			//编辑线路
			editDriverLineList(index){
				//为了回显到弹窗上
				this.editDriverLineIndex=index
				this.arriveDistrict=this.formData.driverLineList[index].arriveDistrict
				this.arriveDistrictName=this.formData.driverLineList[index].arriveDistrictName
				this.departDistrict=this.formData.driverLineList[index].departDistrict
				this.departDistrictName=this.formData.driverLineList[index].departDistrictName
				this.$refs.alertDialog.open()
			},
			//删除线路
			deleteDriverLineList(index){
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定删除此线路？',
					success: function (res) {
						if (res.confirm) {
							that.formData.driverLineList.splice(index,1)
						}
					}
				});
			},
			//新增路线
			addLine(){
				this.arriveDistrict=''
				this.departDistrict=''
				this.departDistrictName=''
				this.arriveDistrictName=''
				this.editDriverLineIndex=''
				this.$refs.alertDialog.open()
			},
			//确认新增路线
			dialogConfirm() {
				if(!this.departDistrict)
				{
					uni.showToast({
						title: '起始地址不能为空',
						icon:'none'
					})
					return
				}
				if(!this.arriveDistrict)
				{
					uni.showToast({
						title: '目的地址不能为空',
						icon:'none'
					})
					return
				}
				if(this.editDriverLineIndex==='')  //新增
				{
					this.formData.driverLineList.push({
						arriveDistrict:this.arriveDistrict,
						arriveDistrictName:this.arriveDistrictName,
						departDistrict:this.departDistrict,
						departDistrictName:this.departDistrictName
					})
				}
				else   //编辑
				{
					this.formData.driverLineList.splice(this.editDriverLineIndex,1,{
						arriveDistrict:this.arriveDistrict,
						arriveDistrictName:this.arriveDistrictName,
						carrierDriverId:this.formData.driverId,
						departDistrict:this.departDistrict,
						departDistrictName:this.departDistrictName,
					})
				}
				//关闭弹窗
				this.$refs.alertDialog.close()
			},
			//新增路线弹窗选择起始地址
			getDepartDistrictName(e){
				if(e.detail.value.length) this.departDistrictName=e.detail.value[0].text+e.detail.value[1].text+e.detail.value[2].text;
				else this.departDistrictName='';
				
			},
			//新增路线弹窗选择目的地址
			getArriveDistrictName(e){
				if(e.detail.value.length) this.arriveDistrictName=e.detail.value[0].text+e.detail.value[1].text+e.detail.value[2].text;
				else this.arriveDistrictName='';
			},
			//提交新增司机
			submit() {
				let that = this
				this.$refs.form.validate().then(res => {
					// if(!isSupervisor)
					// {
					// 	uni.showToast({
					// 		title: '请在【服务人员】中设置一名主管',
					// 		icon:'none'
					// 	})
					// 	return
					// }
					
					uni.showLoading({
						title: '正在提交...',
					})
					
					addDriver(that.formData).then(res => {
						uni.hideLoading()
						if (res.code == '200') {
							uni.showToast({
								title: '提交成功',
								icon: 'none'
							})
							let pages = getCurrentPages(); // 获取当前页面栈的实例，以数组形式按栈的顺序给出，第一个元素为首页，最后一个元素为当前页面。
							let nowPage = pages[pages.length - 1]; //当前页页面实例
							let prevPage = pages[pages.length - 2]; //上一页页面实例
							prevPage.$vm.otherFun('3') // 給上一頁綁定方法otherFun,傳參0（tabIndex：0）
							uni.navigateBack({
								delta: 1 // 可以不傳delta值，默認為1
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						}
					})
				}).catch(err => {
					uni.showToast({
						title: err[0].errorMessage,
						icon: 'none'
					})
				})
			},
			//修改司机
			submit_update() {
				let that = this
				this.$refs.form.validate().then(res => {
					
					// if(!isSupervisor)
					// {
					// 	uni.showToast({
					// 		title: '请在【服务人员】中设置一名主管',
					// 		icon:'none'
					// 	})
					// 	return
					// }
					
					if(this.isOpenAccount=='1') //当前已经开通账号
					{
						this.formData.openAccount=this.formData.phoneNumber;
					}
					
					uni.showLoading({
						title: '正在提交...',
					})

					that.formData.driverId = that.driverId
					updateDriverProfile(that.formData).then(res => {
						uni.hideLoading()
						if (res.code == '200') {
							uni.showToast({
								title: '修改成功',
								icon: 'none'
							})
							let pages = getCurrentPages(); // 获取当前页面栈的实例，以数组形式按栈的顺序给出，第一个元素为首页，最后一个元素为当前页面。
							let nowPage = pages[pages.length - 1]; //当前页页面实例
							let prevPage = pages[pages.length - 2]; //上一页页面实例
							prevPage.$vm.otherFun('3') // 給上一頁綁定方法otherFun,傳參0（tabIndex：0）
							setTimeout(() => {
								uni.navigateBack({
									delta: 1 // 可以不傳delta值，默認為1
								})
							}, 1000)
						} else {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						}
					})
				}).catch(err => {
					uni.showToast({
						title: err[0].errorMessage,
						icon: 'none'
					})
				})
			},
		},
	}
</script>

<style scoped>
	.pagecontrol-top-scroll {
		height: 40px;
		width: 100%;
		white-space: nowrap;
		box-sizing: border-box;
		border-bottom: 1rpx solid #ededed;
		background-color: #f8f8f8;
	}

	.pagecontrol-top-title {
		height: 100%;
		width: 100%;
		display: flex;
		justify-content: space-around;
	}

	.pagecontrol-top-text {
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
	}

	.pagecontrol-top-normal {
		color: #656565;
		font-size: 16px;
	}

	.pagecontrol-top-selected {
		color: #000000;
		font-weight: bold;
		font-size: 16px;
	}

	.pagecontrol-bottom-line {
		width: 50vw;
		height: 3px;
		margin-top: 8px;
		background-color: #bf5f09;
		border-radius: 11px;
	}

	.pagecontrol-bottom-line-show {
		visibility: visible;
	}

	.pagecontrol-bottom-line-visibility {
		visibility: hidden;
	}

	.buttonHover {
		opacity: 0.6;
	}
	::v-deep .file-title{
	    font-size: 12px;
	    color: #333;
	}
	
	
	::v-deep .uni-forms-item__content{
		width: 0vw;
	}
	
	::v-deep .uni-border-left{
	    border-left-color: #f0f0f0;
	    border-left-style: solid;
	    border-left-width: 1px;
	    background-color: rgb(157,81,38);
	    border-radius: 0 0 11px 0;
	    /* color: white; */
	}
	::v-deep .uni-button-color{
	    color: #ffffff;
	}
</style>